package com.bsh.repository;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import com.bsh.mybatis.IRepository.H_hotelMapper;

/** 
 *
 *
 * @author  kms 
 * @date 创建时间：2016年11月24日 下午12:21:06 
 * @version 1.0  
 */
@Repository
public class DaoHotel {
	@Resource
	SqlSessionTemplate session;

	@Resource
	JdbcTemplate jdbcTemplate;
	@Resource
	NamedParameterJdbcTemplate namedJdbcTemplate;
	
	H_hotelMapper getMapper() {
		return session.getMapper(H_hotelMapper.class);
	}
	
	public List<Map<String,Object>> getAll(){
		StringBuilder sb = new StringBuilder();
		MapSqlParameterSource ps = new MapSqlParameterSource();
		sb.append("select h.id as id,m.merchant_name  from h_hotel h LEFT JOIN merchant m on m.id=h.merchant_id");
		
		List<Map<String, Object>> list = namedJdbcTemplate.queryForList(sb.toString(), ps);

		return list;
	}
}
